﻿#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
using namespace std;

//迭代器失效
int main()
{

	int ar[] = { 1,2,3,4,0,5,6,7,8,9 };

	int n = sizeof(ar) / sizeof(int);

	vector<int> v(ar, ar + n);
	v.reserve(100);
	vector<int>::iterator it = v.begin()+3;
	
	v.erase(++it);
	//v.erase(++it);
	
	return 0;

}



//leetcode17. 电话号码的字母组合
class Solution {
    string str[10] = { "", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
public:
    //多叉树的深度优先遍历
    void _letterCombinations(vector<string>& vs, const string& s, vector<string>& ret, string digits, int i)
    {
        if (i == digits.size())
        {
            ret.push_back(s);
            return;
        }
        int num = digits[i] - '0';//找digits中的元素对应下标
        string tmp = vs[num];//临时的string对象记录下标对应数据
        for (int j = 0; j < tmp.size(); j++)
        {
            _letterCombinations(vs, s + tmp[j], ret, digits, i + 1);
        }

    }
    vector<string> letterCombinations(string digits) {

        if (digits.size() == 0)
            return vector<string>();
        vector<string> vs(str, str + 10);//数字码(初始化时这里要+10)
        vector<string> ret;//返回值
        string s;//顺序容器里的每一组数据
        int i = 0;//digits下标
        _letterCombinations(vs, s, ret, digits, i);
        return ret;

    }
};

